package com.example.gybicycle.controller.common;

import com.example.gybicycle.common.Log.SysLoging;
import com.example.gybicycle.common.entity.Result;

import com.example.gybicycle.common.util.DataUtil;
import com.example.gybicycle.common.util.TreeUtil;
import com.example.gybicycle.dao.*;
import com.example.gybicycle.entity.*;
import com.example.gybicycle.service.BikePointService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Tag(name = "下拉管理")
@RequestMapping("/select")
public class SelectController {
    @Autowired
    private SysRoleDao roleDao;
    @Autowired
    private SysMenuDao menuDao;
    @Autowired
    private LockDao lockDao;
    @Autowired
    private BikePointDao pointDao;
    @Autowired
    private SysDictDao dictDao;

    @PostMapping("/menu")
    @Operation(summary =  "获取菜单")
    public Result menu(@RequestBody(required=false) SysMenu page){
        List<SysMenu> list=menuDao.findList(page);
        list= TreeUtil.menuToTrees(list,0);
        return Result.success(list);
    }
    @PostMapping("/role")
    @Operation(summary =  "获取角色")
    public Result role(@RequestBody(required=false) SysRole page){
        List<SysRole> list=roleDao.findList(page);
        return Result.success(list);
    }
    @PostMapping("/lock")
    @Operation(summary =  "停车点获取空闲锁")
    public Result<List<LockSel>> lock(){
        List<LockSel> list=lockDao.findSelect(new Lock());
        return Result.success(list);
    }
    @PostMapping("/point")
    @Operation(summary =  "停车点获取空闲锁")
    public Result<List<BikePoint>> point(){
        List<BikePoint> list=pointDao.findList(new BikePoint());
        return Result.success(list);
    }
    @PostMapping("/test")
    @Operation(summary =  "测试")
    public Result test(@RequestBody(required=false) SysRole page){
        if(page==null)
            page=new SysRole();
        return Result.success(page);
    }
    @PostMapping("/bikeType")
    @Operation(summary =  "获取车辆类型")
    public Result<List<SysDictData>> bikeType(){
        List<SysDictData> list=dictDao.findSign("bike_type");
        return Result.success(list);
    }
    @PostMapping("/failureType")
    @Operation(summary =  "获取故障类型")
    public Result<List<SysDictData>> failureType(){
        List<SysDictData> list=dictDao.findSign("failure_type");
        return Result.success(list);
    }

}
